/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jsf;

import ejb.PagoFacade;
import entity.Pago;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author mbvierci
 */
@ManagedBean
@RequestScoped
public class PagoBean {
    
    @EJB
    private PagoFacade pagoFacade;
    private Pago pago = new Pago();
    private List<Pago> pagos;

    /**
     * Creates a new instance of PagoBean
     */
    public PagoBean() {
    }
    
     public Pago getPago() {
        return pago;
    }

    public void setPago(Pago pago) {
        this.pago = pago;
    }

    public PagoFacade getPagoFacade() {
        return pagoFacade;
    }

    public void setPagoFacade(PagoFacade pagoFacade) {
        this.pagoFacade = pagoFacade;
        pagos = pagoFacade.findAll();
    }

    public List<Pago> getPagos() {
        return pagos;
    }

    public void setPagos(List<Pago> pagos) {
        this.pagos = pagos;
    }
    
    public void crearPago(){
        pagoFacade.create(pago);
        pagos.add(pago);
        pago = new Pago();
    }
    
     public void deletePago() {
         
       pagoFacade.remove(pago);
    }
}
